<template>
    <div>
        <Table ref="dataTable" highlight-row stripe :loading="table.loading" :columns="table.tableColumns" :data="table.tableRows"
               style="margin-top:20px;" @on-sort-change="changeSort"></Table>
        <div style="margin: 20px; overflow: hidden">
            <div style="float: right;">
                <Page :total="pager.total" :current="pager.pageNo" @on-change="changePageNo" @on-page-size-change="changePageSize"
                      showSizer showTotal></Page>
            </div>
        </div>
    </div>
</template>

<script>
    import * as utils from '@/api/utils-v2'

    export default {
        name: 'AccountDetailTableShow',
        data() {
            return {
                urls: {
                    searchUrl: '/account-detail/admin/pager-cond'
                },
                pager: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },
				dataDictCodes: ['IS_ACTIVE', 'ACCOUNT_STATUS', 'INCOME_OUTGOING_TYPE', 'PAYMENT_TYPE','FUNDS_CHANGE_TYPE'],
				dataDictItems: {},
                searchOpts: {
                    sortColumn: null,
                    sortOrder: null,
                },
                table: {
                    loading: false,
                    tableColumns: [{
                        width: 60,
                        align: 'center',
                        fixed: 'left',
                        render: (h, params) => {
                            return h('span', params.index + (this.pager.pageNo - 1) * this.pager.pageSize + 1)
                        }
                    },
                        {
title: '账目编号',
key: 'id',
minWidth: 120,
sortable: true,
},
{
title: '交易编号',
key: 'transactionNo',
minWidth: 120,
sortable: true,
},
{
title: '用户编号',
key: 'userId',
minWidth: 120,
sortable: true,
},
{
title: '金额（元）',
key: 'amount',
minWidth: 120,
sortable: true,
},
{
title: '积分',
key: 'integral',
minWidth: 120,
sortable: true,
},
{
title: '收入或支出',
key: 'type',
minWidth: 120,
sortable: true,
render: (h, params) => {
    let dictItem = utils.getDataDictItemDisplayValue(this, 'INCOME_OUTGOING_TYPE', params.row.type)
  return h('Tag',{
    props: {
      color: dictItem.color
    }
  }, dictItem.displayValue) 
}
},
{
title: '收支类型',
key: 'subType',
minWidth: 120,
sortable: true,
render: (h, params) => {
        let dictItem = utils.getDataDictItemDisplayValue(this, 'FUNDS_CHANGE_TYPE', params.row.subType)
        return h('span', dictItem.displayValue)
 }

},
{
title: '支付方式',
key: 'payType',
minWidth: 120,
sortable: true,
render: (h, params) => {
    let dictItem = utils.getDataDictItemDisplayValue(this, 'PAYMENT_TYPE', params.row.payType)
    return h('span', dictItem.displayValue) 
}
},
{
title: '账目备注',
key: 'remark',
minWidth: 120,
sortable: true,
},
{
title: '账目状态',
key: 'accountStatus',
minWidth: 120,
sortable: true,
render: (h, params) => {
    let dictItem = utils.getDataDictItemDisplayValue(this, 'ACCOUNT_STATUS', params.row.accountStatus)
    return h('span', dictItem.displayValue) 
}
},
{
title: '版本号',
key: 'version',
minWidth: 120,
sortable: true,
renderHeader: (h, params) => {
              return h('span', [
                h('span', '版本号'),
                h('Tooltip', {
                  props: {
                    content: '账目版本号',
                    placement: 'top',
                    transfer: true,
                    maxWidth: 500
                  }
                }, [
                  h('Icon', {
                    props: {
                      type: 'ios-help-circle'
                    },
                    style: {
                      marginLeft: '3px'
                    }
                  })
                ])
              ])
            }
},
{
title: '创建时间',
key: 'createTime',
minWidth: 120,
sortable: true,
renderHeader: (h, params) => {
              return h('span', [
                h('span', '创建时间'),
                h('Tooltip', {
                  props: {
                    content: '账目创建时间',
                    placement: 'top',
                    transfer: true,
                    maxWidth: 500
                  }
                }, [
                  h('Icon', {
                    props: {
                      type: 'ios-help-circle'
                    },
                    style: {
                      marginLeft: '3px'
                    }
                  })
                ])
              ])
            }
},
{
title: '更新时间',
key: 'updateTime',
minWidth: 120,
sortable: true,
renderHeader: (h, params) => {
              return h('span', [
                h('span', '更新时间'),
                h('Tooltip', {
                  props: {
                    content: '账目更新时间',
                    placement: 'top',
                    transfer: true,
                    maxWidth: 500
                  }
                }, [
                  h('Icon', {
                    props: {
                      type: 'ios-help-circle'
                    },
                    style: {
                      marginLeft: '3px'
                    }
                  })
                ])
              ])
            }
},
{
title: '是否激活',
key: 'isActive',
minWidth: 120,
sortable: true,
renderHeader: (h, params) => {
              return h('span', [
                h('span', '是否激活'),
                h('Tooltip', {
                  props: {
                    content: '账目是否激活',
                    placement: 'top',
                    transfer: true,
                    maxWidth: 500
                  }
                }, [
                  h('Icon', {
                    props: {
                      type: 'ios-help-circle'
                    },
                    style: {
                      marginLeft: '3px'
                    }
                  })
                ])
              ])
            },
			render: (h, params) => {
			        let dictItem = utils.getDataDictItemDisplayValue(this, 'IS_ACTIVE', params.row.isActive)
			        return h('span', dictItem.displayValue)
			 }
},

                        {
                            title: '激活状态',
                            key: 'isActive',
                            minWidth: 100,
                            align: 'center',
                            render: (h, params) => {
                                return h('span', params.row.isActive === 0 ? '激活': '冻结')
                            }
                        },
                        {
                            title: "操作",
                            key: "action",
                            width: 130,
                            align: "center",
                            fixed: "right",
                            render: (h, params) => {
                                return h(
                                    "Dropdown",
                                    {
                                        on: {
                                            "on-click": itemName => {
                                                this.userOpt(itemName, params.row);
                                            }
                                        },
                                        props: {
                                            transfer: true
                                        }
                                    },
                                    [
                                        h(
                                            "Button",
                                            {
                                                props: {
                                                    type: "primary",
                                                    size: "small"
                                                }
                                            },
                                            [
                                                "选择操作 ",
                                                h("Icon", {
                                                    props: {
                                                        type: "ios-arrow-down"
                                                    }
                                                })
                                            ]
                                        ),
                                        h(
                                            "DropdownMenu",
                                            {
                                                slot: "list"
                                            },
                                            [
                                                h(
                                                    "DropdownItem",
                                                    {
                                                        props: {
                                                            name: "showDetail"
                                                        }
                                                    },
                                                    "详情"
                                                )
                                            ]
                                        )
                                    ]
                                );
                            }
                        }
                    ],
                    tableRows: [],
                    selections: []
                }
            }
        },
        computed: {},
        mounted() {
            this.search()
        },
        methods: {
            search() {
                this.$emit('searchTable')
            },
            userOpt(itemName, row) {
                if (itemName === "showDetail") {
                    this.$emit('showDetailModal', JSON.parse(JSON.stringify(row)))
                }
            },
            
            changeSort(sortColumn) {
                utils.changeSort(this, sortColumn)
            },
            changePageNo(pageNo) {
                utils.changePageNo(this, pageNo)
            },
            changePageSize(pageSize) {
                utils.changePageSize(this, pageSize)
            }
        }
    }
</script>

<style>
</style>
